<?php

namespace maotool\src\test;

use maotool\cache\CacheUtil;
use maotool\cache\Driver;
use maotool\core\config\ProxyConfig;
use maotool\core\Container;
use maotool\core\facade\Cache;
use maotool\core\facade\Config;
use maotool\file\DirUtil;
use maotool\file\FileUtil;
use maotool\log\Console;
use maotool\object\ReflectionUtil;
use maotool\util\IdUtil;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

class ConfigUtilTest extends TestCase
{

    public function testDemo1()
    {
        $log_time_start = microtime(true);
        $config = Config::get("framework");
        Console::debug('请求加载用时：' . number_format(microtime(true) - $log_time_start, 10) . ' 秒。');
        $lines = Console::$lines;
        foreach ($lines as $line) {
            echo json_encode($line["ages"], JSON_UNESCAPED_UNICODE) . "\n";
        }
        $d_cache = DirUtil::$cache;
        $f_cache = FileUtil::$cache;
        $r_cache = ReflectionUtil::$cache;
        $this->assertTrue(true);
    }

    public function testDemo2()
    {
        var_dump(CacheUtil::has("test"));
        $data = CacheUtil::get("test", "default");
        var_dump($data);
        CacheUtil::put("test", IdUtil::simpleUUID());
        $data = CacheUtil::get("test", "default");
        var_dump($data);
        $this->assertTrue(true);
    }

    public function testDemo3()
    {
        Config::set("wl.config", ["666"]);
        Config::set("wl.config.test", ["666"]);
        Config::set("wl.env", new ProxyConfig(function () {
            return [
                "test" => "default",
                "prod" => "demo1",
            ];
        }));
        $config = Config::get('wl.config.0');
        echo json_encode($config);
        $this->assertTrue(true);
    }

}